<!DOCTYPE html>
<html lang="zh">

<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
	<meta name="keywords" content="dromara.org" />
	<meta name="description" content="dromara.org" />
	<!-- 网页标签标题 -->
	<title>dromara(Open source organization)</title>
	<link rel="shortcut icon" href="/website/img/docsite.ico"/>
	<link rel="stylesheet" href="/website/build/documentation.css" />
</head>
<body>
	<div id="root"><div class="documentation-page" data-reactroot=""><header class="header-container header-container-normal"><div class="header-body"><a href="/website/zh-cn/index.html"><img class="logo" src="/website/img/dromara.png"/></a><div class="search search-normal"><span class="icon-search"></span></div><span class="language-switch language-switch-normal">En</span><div class="header-menu"><img class="header-menu-toggle" src="/website/img/system/menu_gray.png"/><ul><li class="menu-item menu-item-normal"><a href="/website/zh-cn/index.html" target="_self">首页</a><div class="sub-menu"><ul></ul></div></li><li class="menu-item menu-item-normal menu-item-normal-active"><a href="#">文档</a><div class="sub-menu"><ul><li><a href="/website/zh-cn/docs/soul/soul.html" target="_self">Soul</a></li><li><a href="/website/zh-cn/docs/hmily/index.html" target="_self">Hmily</a></li></ul></div></li><li class="menu-item menu-item-normal"><a href="/website/zh-cn/blog/index.html" target="_self">博客</a><div class="sub-menu"><ul></ul></div></li><li class="menu-item menu-item-normal"><a href="/website/zh-cn/community/index.html" target="_self">社区</a><div class="sub-menu"><ul></ul></div></li></ul></div></div></header><section class="content-section"><div class="sidemenu" id="menu"><div class="sidemenu-toggle"><img src="https://img.alicdn.com/tfs/TB1E6apXHGYBuNjy0FoXXciBFXa-200-200.png"/></div><ul><li class="menu-item menu-item-level-1"><span>Soul</span><ul><li style="height:36px;overflow:hidden" class="menu-item menu-item-level-2"><a href="/website/zh-cn/docs/soul/soul.html" target="_self">soul介绍</a></li><li style="height:36px;overflow:hidden" class="menu-item menu-item-level-2"><a href="/website/zh-cn/docs/soul/team.html" target="_self">团队介绍</a></li><li style="height:36px;overflow:hidden" class="menu-item menu-item-level-2"><a href="/website/zh-cn/docs/soul/induction.html" target="_self">soul极简入门</a></li><li style="height:36px;overflow:hidden" class="menu-item menu-item-level-2"><a href="/website/zh-cn/docs/soul/db.html" target="_self">数据库设计</a></li><li style="height:36px;overflow:hidden" class="menu-item menu-item-level-2"><a href="/website/zh-cn/docs/soul/config.html" target="_self">数据配置流程</a></li><li style="height:36px;overflow:hidden" class="menu-item menu-item-level-2"><a href="/website/zh-cn/docs/soul/dataSync.html" target="_self">数据同步原理</a></li><li style="height:36px;overflow:hidden" class="menu-item menu-item-level-2"><a href="/website/zh-cn/docs/soul/metaData.html" target="_self">元数据概念介绍</a></li><li style="height:684px;overflow:hidden" class="menu-item menu-item-level-2"><span>用户使用文档<img style="transform:rotate(0deg)" class="menu-toggle" src="/website/img/system/arrow_down.png"/></span><ul><li class="menu-item menu-item-level-3"><a href="/website/zh-cn/docs/soul/setup.html" target="_self">搭建soul网关环境</a></li><li class="menu-item menu-item-level-3"><a href="/website/zh-cn/docs/soul/user-http.html" target="_self">http用户</a></li><li class="menu-item menu-item-level-3"><a href="/website/zh-cn/docs/soul/user-dubbo.html" target="_self">dubbo用户</a></li><li class="menu-item menu-item-level-3"><a href="/website/zh-cn/docs/soul/user-springcloud.html" target="_self">springCloud用户</a></li><li class="menu-item menu-item-level-3"><a href="/website/zh-cn/docs/soul/user-sofa.html" target="_self">sofa用户</a></li><li class="menu-item menu-item-level-3"><a href="/website/zh-cn/docs/soul/selector.html" target="_self">选择器规则详解</a></li><li class="menu-item menu-item-level-3"><a href="/website/zh-cn/docs/soul/user-dataSync.html" target="_self">数据同步策略</a></li><li class="menu-item menu-item-level-3"><a href="/website/zh-cn/docs/soul/plugin-divide.html" target="_self">divide插件</a></li><li class="menu-item menu-item-level-3"><a href="/website/zh-cn/docs/soul/plugin-dubbo.html" target="_self">dubbo插件</a></li><li class="menu-item menu-item-level-3"><a href="/website/zh-cn/docs/soul/plugin-springcloud.html" target="_self">springcloud插件</a></li><li class="menu-item menu-item-level-3"><a href="/website/zh-cn/docs/soul/plugin-sofa.html" target="_self">sofa插件</a></li><li class="menu-item menu-item-level-3"><a href="/website/zh-cn/docs/soul/plugin-rateLimiter.html" target="_self">rateLimiter插件</a></li><li class="menu-item menu-item-level-3"><a href="/website/zh-cn/docs/soul/plugin-hystrix.html" target="_self">hystrix插件</a></li><li class="menu-item menu-item-level-3"><a href="/website/zh-cn/docs/soul/plugin-monitor.html" target="_self">monitor插件</a></li><li class="menu-item menu-item-level-3"><a href="/website/zh-cn/docs/soul/plugin-waf.html" target="_self">waf插件</a></li><li class="menu-item menu-item-level-3"><a href="/website/zh-cn/docs/soul/plugin-sign.html" target="_self">sign插件</a></li><li class="menu-item menu-item-level-3"><a href="/website/zh-cn/docs/soul/plugin-rewrite.html" target="_self">rewrite插件</a></li><li class="menu-item menu-item-level-3"><a href="/website/zh-cn/docs/soul/plugin-websocket.html" target="_self">websocket支持</a></li></ul></li><li style="height:360px;overflow:hidden" class="menu-item menu-item-level-2"><span>开发者文档<img style="transform:rotate(0deg)" class="menu-toggle" src="/website/img/system/arrow_down.png"/></span><ul><li class="menu-item menu-item-level-3"><a href="/website/zh-cn/docs/soul/dev-filter.html" target="_self">自定义filter</a></li><li class="menu-item menu-item-level-3"><a href="/website/zh-cn/docs/soul/dev-plugin.html" target="_self">自定义插件</a></li><li class="menu-item menu-item-level-3"><a href="/website/zh-cn/docs/soul/dev-file.html" target="_self">文件上传下载</a></li><li class="menu-item menu-item-level-3"><a href="/website/zh-cn/docs/soul/dev-iphost.html" target="_self">自定义解析IP与host</a></li><li class="menu-item menu-item-level-3"><a href="/website/zh-cn/docs/soul/dev-result.html" target="_self">自定义返回结果</a></li><li class="menu-item menu-item-level-3"><a href="/website/zh-cn/docs/soul/dev-sign.html" target="_self">自定义签名插件算法与验证</a></li><li class="menu-item menu-item-level-3"><a href="/website/zh-cn/docs/soul/dev-client.html" target="_self">多语言http客户端接入</a></li><li class="menu-item menu-item-level-3"><a href="/website/zh-cn/docs/soul/dev-thread.html" target="_self">线程模型</a></li><li class="menu-item menu-item-level-3"><a href="/website/zh-cn/docs/soul/dev-netty.html" target="_self">soul调优</a></li></ul></li><li style="height:144px;overflow:hidden" class="menu-item menu-item-level-2"><span>社区贡献<img style="transform:rotate(0deg)" class="menu-toggle" src="/website/img/system/arrow_down.png"/></span><ul><li class="menu-item menu-item-level-3"><a href="/website/zh-cn/docs/soul/contributor.html" target="_self">贡献者指南</a></li><li class="menu-item menu-item-level-3"><a href="/website/zh-cn/docs/soul/committer.html" target="_self">提交者指南</a></li><li class="menu-item menu-item-level-3"><a href="/website/zh-cn/docs/soul/code-conduct.html" target="_self">编码规范</a></li></ul></li></ul></li></ul></div><div class="doc-content markdown-body" id="doc-body"><h2>说明</h2>
<ul>
<li>
<p>数据同步是指将 <code>soul-admin</code> 配置的数据，同步到 <code>soul</code> 集群中的JVM内存里面，是网关高性能的关键。</p>
</li>
<li>
<p>实现原理，请看： <a href="dataSync.md">数据同步</a>。</p>
</li>
<li>
<p>文中所说的网关，是指你搭建的网关环境，请看：<a href="setup.md">搭建环境</a>。</p>
</li>
</ul>
<h2>websocket同步（默认方式，推荐）</h2>
<ul>
<li>
<p>网关配置（记得重启）</p>
<ul>
<li>首先在 <code>pom.xml</code> 文件中 引入以下依赖：</li>
</ul>
</li>
</ul>
<pre><code class="language-xml">   <span class="hljs-comment">&lt;!--soul data sync start use websocket--&gt;</span>
   <span class="hljs-tag">&lt;<span class="hljs-name">dependency</span>&gt;</span>
     <span class="hljs-tag">&lt;<span class="hljs-name">groupId</span>&gt;</span>org.dromara<span class="hljs-tag">&lt;/<span class="hljs-name">groupId</span>&gt;</span>
     <span class="hljs-tag">&lt;<span class="hljs-name">artifactId</span>&gt;</span>soul-spring-boot-starter-sync-data-websocket<span class="hljs-tag">&lt;/<span class="hljs-name">artifactId</span>&gt;</span>
     <span class="hljs-tag">&lt;<span class="hljs-name">version</span>&gt;</span>${last.version}<span class="hljs-tag">&lt;/<span class="hljs-name">version</span>&gt;</span>
   <span class="hljs-tag">&lt;/<span class="hljs-name">dependency</span>&gt;</span>
</code></pre>
<ul>
<li>在 springboot的 yml 文件中进行如下配置:</li>
</ul>
<pre><code class="language-yaml"><span class="hljs-attr">soul :</span>
    <span class="hljs-attr">sync:</span>
        <span class="hljs-attr">websocket :</span>
             <span class="hljs-attr">urls:</span> <span class="hljs-string">ws://localhost:9095/websocket</span>
<span class="hljs-comment">#urls:是指 soul-admin的地址，如果有多个，请使用（,）分割.</span>
</code></pre>
<ul>
<li>soul-admin 配置, 或在 soul-admin 启动参数中设置 <code>--soul.sync.websocket=''</code>,然后重启服务。</li>
</ul>
<pre><code class="language-yaml"><span class="hljs-attr">soul:</span>
  <span class="hljs-attr">sync:</span>
     <span class="hljs-attr">websocket:</span>
</code></pre>
<ul>
<li>
<p>当建立连接以后会全量获取一次数据，以后的数据都是增量的更新与新增，性能好。</p>
</li>
<li>
<p>支持断线重连 （默认30秒）。</p>
</li>
</ul>
<h2>zookeeper同步</h2>
<ul>
<li>
<p>网关配置（记得重启）</p>
<ul>
<li>首先在 <code>pom.xml</code> 文件中 引入以下依赖：</li>
</ul>
</li>
</ul>
<pre><code class="language-xml">   <span class="hljs-comment">&lt;!--soul data sync start use zookeeper--&gt;</span>
     <span class="hljs-tag">&lt;<span class="hljs-name">dependency</span>&gt;</span>
          <span class="hljs-tag">&lt;<span class="hljs-name">groupId</span>&gt;</span>org.dromara<span class="hljs-tag">&lt;/<span class="hljs-name">groupId</span>&gt;</span>
           <span class="hljs-tag">&lt;<span class="hljs-name">artifactId</span>&gt;</span>soul-spring-boot-starter-sync-data-zookeeper<span class="hljs-tag">&lt;/<span class="hljs-name">artifactId</span>&gt;</span>
           <span class="hljs-tag">&lt;<span class="hljs-name">version</span>&gt;</span>${last.version}<span class="hljs-tag">&lt;/<span class="hljs-name">version</span>&gt;</span>
     <span class="hljs-tag">&lt;/<span class="hljs-name">dependency</span>&gt;</span>
</code></pre>
<ul>
<li>在 springboot的 yml 文件中进行如下配置:</li>
</ul>
<pre><code class="language-yaml"> <span class="hljs-attr">soul :</span>
     <span class="hljs-attr">sync:</span>
         <span class="hljs-attr">zookeeper:</span>
              <span class="hljs-attr">url:</span> <span class="hljs-string">localhost:2181</span>
              <span class="hljs-attr">sessionTimeout:</span> <span class="hljs-number">5000</span>
              <span class="hljs-attr">connectionTimeout:</span> <span class="hljs-number">2000</span>
 <span class="hljs-comment">#url: 配置成你的zk地址，集群环境请使用（,）分隔</span>
</code></pre>
<ul>
<li>soul-admin 配置, 或在 soul-admin 启动参数中设置 <code>--soul.sync.zookeeper.url='你的地址'</code>,然后重启服务。</li>
</ul>
<pre><code class="language-yaml"><span class="hljs-attr">soul:</span>
  <span class="hljs-attr">sync:</span>
    <span class="hljs-attr">zookeeper:</span>
        <span class="hljs-attr">url:</span> <span class="hljs-string">localhost:2181</span>
        <span class="hljs-attr">sessionTimeout:</span> <span class="hljs-number">5000</span>
        <span class="hljs-attr">connectionTimeout:</span> <span class="hljs-number">2000</span>
</code></pre>
<ul>
<li>使用zookeeper同步机制也是非常好的,时效性也高，我们生产环境使用的就是这个，但是也要处理zk环境不稳定，集群脑裂等问题.</li>
</ul>
<h2>http长轮询同步</h2>
<ul>
<li>
<p>网关配置（记得重启）</p>
<ul>
<li>首先在 <code>pom.xml</code> 文件中 引入以下依赖：</li>
</ul>
</li>
</ul>
<pre><code class="language-xml">   <span class="hljs-comment">&lt;!--soul data sync start use zookeeper--&gt;</span>
     <span class="hljs-tag">&lt;<span class="hljs-name">dependency</span>&gt;</span>
          <span class="hljs-tag">&lt;<span class="hljs-name">groupId</span>&gt;</span>org.dromara<span class="hljs-tag">&lt;/<span class="hljs-name">groupId</span>&gt;</span>
           <span class="hljs-tag">&lt;<span class="hljs-name">artifactId</span>&gt;</span>soul-spring-boot-starter-sync-data-http<span class="hljs-tag">&lt;/<span class="hljs-name">artifactId</span>&gt;</span>
           <span class="hljs-tag">&lt;<span class="hljs-name">version</span>&gt;</span>${last.version}<span class="hljs-tag">&lt;/<span class="hljs-name">version</span>&gt;</span>
     <span class="hljs-tag">&lt;/<span class="hljs-name">dependency</span>&gt;</span>
</code></pre>
<ul>
<li>在 springboot的 yml 文件中进行如下配置:</li>
</ul>
<pre><code class="language-yaml"><span class="hljs-attr">soul :</span>
   <span class="hljs-attr">sync:</span>
       <span class="hljs-attr">http:</span>
            <span class="hljs-attr">url:</span> <span class="hljs-string">http://localhost:9095</span>
<span class="hljs-comment">#url: 配置成你的 soul-admin的 ip与端口地址，多个admin集群环境请使用（,）分隔。</span>
</code></pre>
<ul>
<li>soul-admin 配置, 或在 soul-admin 启动参数中设置 <code>--soul.sync.http=''</code>,然后重启服务。</li>
</ul>
<pre><code class="language-yaml"><span class="hljs-attr">soul:</span>
  <span class="hljs-attr">sync:</span>
     <span class="hljs-attr">http:</span>
</code></pre>
<ul>
<li>
<p>http长轮询使得网关很轻量，时效性略低。</p>
</li>
<li>
<p>其根据分组key来拉取，如果数据量过大，过多，会有一定的影响。 什么意思呢？就是一个组下面的一个小地方更改，会拉取整个的组数据。</p>
</li>
<li>
<p>在soul-admin 集群时候，可能会有bug。</p>
</li>
</ul>
<h2>nacos同步</h2>
<ul>
<li>
<p>网关配置（记得重启）</p>
<ul>
<li>首先在 <code>pom.xml</code> 文件中 引入以下依赖：</li>
</ul>
</li>
</ul>
<pre><code class="language-xml">   <span class="hljs-comment">&lt;!--soul data sync start use zookeeper--&gt;</span>
     <span class="hljs-tag">&lt;<span class="hljs-name">dependency</span>&gt;</span>
          <span class="hljs-tag">&lt;<span class="hljs-name">groupId</span>&gt;</span>org.dromara<span class="hljs-tag">&lt;/<span class="hljs-name">groupId</span>&gt;</span>
           <span class="hljs-tag">&lt;<span class="hljs-name">artifactId</span>&gt;</span>soul-spring-boot-starter-sync-data-nacos<span class="hljs-tag">&lt;/<span class="hljs-name">artifactId</span>&gt;</span>
           <span class="hljs-tag">&lt;<span class="hljs-name">version</span>&gt;</span>${last.version}<span class="hljs-tag">&lt;/<span class="hljs-name">version</span>&gt;</span>
     <span class="hljs-tag">&lt;/<span class="hljs-name">dependency</span>&gt;</span>
</code></pre>
<ul>
<li>在 springboot的 yml 文件中进行如下配置:</li>
</ul>
<pre><code class="language-yaml"> <span class="hljs-attr">soul :</span>
     <span class="hljs-attr">sync:</span>
        <span class="hljs-attr">nacos:</span>
             <span class="hljs-attr">url:</span> <span class="hljs-string">localhost:8848</span>
             <span class="hljs-attr">namespace:</span> <span class="hljs-string">1c10d748-af86-43b9-8265-75f487d20c6c</span>
             <span class="hljs-attr">acm:</span>
               <span class="hljs-attr">enabled:</span> <span class="hljs-literal">false</span>
               <span class="hljs-attr">endpoint:</span> <span class="hljs-string">acm.aliyun.com</span>
               <span class="hljs-attr">namespace:</span>
               <span class="hljs-attr">accessKey:</span>
               <span class="hljs-attr">secretKey:</span>
 <span class="hljs-comment">#url: 配置成你的nacos地址，集群环境请使用（,）分隔。</span>
 <span class="hljs-comment"># 其他参数配置，请参考naocs官网。</span>
</code></pre>
<ul>
<li>soul-admin 配置, 或在 soul-admin 启动参数中使用 <code>--</code> 的方式一个一个传值。</li>
</ul>
<pre><code class="language-yaml"><span class="hljs-attr">soul :</span>
      <span class="hljs-attr">sync:</span>
         <span class="hljs-attr">nacos:</span>
              <span class="hljs-attr">url:</span> <span class="hljs-string">localhost:8848</span>
              <span class="hljs-attr">namespace:</span> <span class="hljs-string">1c10d748-af86-43b9-8265-75f487d20c6c</span>
              <span class="hljs-attr">acm:</span>
                <span class="hljs-attr">enabled:</span> <span class="hljs-literal">false</span>
                <span class="hljs-attr">endpoint:</span> <span class="hljs-string">acm.aliyun.com</span>
                <span class="hljs-attr">namespace:</span>
                <span class="hljs-attr">accessKey:</span>
                <span class="hljs-attr">secretKey:</span>
</code></pre>
</div></section><footer class="footer-container"><div class="footer-body"><img src="/website/img/dromara.png"/><div class="cols-container"><div class="col col-12"><h3>免责声明</h3><p>任何单位或个人转载本网站的所有相关信息，请注明来源。</p></div><div class="col col-6"><dl><dt>文档</dt><dd><a href="/website/zh-cn/docs/soul/soul.html" target="_self">概览</a></dd><dd><a href="/website/zh-cn/docs/soul/soul.html" target="_self">快速开始</a></dd><dd><a href="/website/zh-cn/docs/soul/soul.html" target="_self">开发者指南</a></dd></dl></div><div class="col col-6"><dl><dt>资源</dt><dd><a href="/website/zh-cn/blog/index.html" target="_self">博客</a></dd><dd><a href="/website/zh-cn/community/index.html" target="_self">社区</a></dd></dl></div></div><div class="copyright"><span>Copyright ©2020 xiaoyu@apache.org by xiaoyu</span></div></div></footer></div></div>
	<script src="https://f.alicdn.com/react/15.4.1/react-with-addons.min.js"></script>
	<script src="https://f.alicdn.com/react/15.4.1/react-dom.min.js"></script>
	<script>
		window.rootPath = '/website';
  </script>
	<script src="/website/build/documentation.js"></script>
</body>
</html>